Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All might legend/issue3333 #3410

Closed

Conversation

AllMightLegend
Copy link

@AllMightLegend AllMightLegend commented Aug 16, 2024

Pull Request Checklist

Signed-off-by: Srinjoy Sen Chowdhury [email protected]

The issue involved ensuring that the ts parameter in Dendrite is correctly handled when the request is from an appservice, and that it is ignored or handled differently when not. The resolution was achieved through the following steps:

Refactoring the Logic:
The logic for processing the ts parameter was refactored into a separate function named HandleEventTimestamp. This function determines whether the request is from an appservice by calling isAppService(req). If it is, the function parses the ts parameter using httputil.ParseTSParam(req). If the request is not from an appservice, the function defaults to using the current time or another appropriate handling.

Updating sendevent.go:
The inline logic in sendevent.go that handled the ts parameter was replaced with a call to the new HandleEventTimestamp function. This ensures that the logic is centralized and can be easily tested and maintained.

Creating Tests:
A new test file, ts_param_test.go, was created in the testing directory. This file includes tests that cover various scenarios:

When the ts parameter is valid and the request is from an appservice.
When the ts parameter is invalid or missing.
When the request is not from an appservice.

Key Features:
Password Configuration:

The PasswordConfig struct allows customization of the password validation requirements. This can be extended to include more complex policies as needed.
YAML Configuration:

The PasswordConfig struct could be loaded from a YAML file, enabling dynamic adjustment of the password requirements without code changes.
Password Validation:

The ValidatePassword function checks the length, presence of uppercase letters, lowercase letters, digits, and special characters based on the provided configuration.
Sidecar Feature:

A placeholder sidecarLogPasswordValidation function is included, where you could integrate with a logging service to track password validation attempts.

Signed-off-by: AllMightLegend [email protected]
The issue involved ensuring that the ts parameter in Dendrite is correctly handled when the request is from an appservice, and that it is ignored or handled differently when not. The resolution was achieved through the following steps:

Refactoring the Logic:
The logic for processing the ts parameter was refactored into a separate function named HandleEventTimestamp. This function determines whether the request is from an appservice by calling isAppService(req). If it is, the function parses the ts parameter using httputil.ParseTSParam(req). If the request is not from an appservice, the function defaults to using the current time or another appropriate handling.

Updating sendevent.go:
The inline logic in sendevent.go that handled the ts parameter was replaced with a call to the new HandleEventTimestamp function. This ensures that the logic is centralized and can be easily tested and maintained.

Creating Tests:
A new test file, ts_param_test.go, was created in the testing directory. This file includes tests that cover various scenarios:

When the ts parameter is valid and the request is from an appservice.
When the ts parameter is invalid or missing.
When the request is not from an appservice.

Signed off by : `Srinjoy Sen Chowdhury [email protected]`
@AllMightLegend AllMightLegend requested a review from a team as a code owner August 16, 2024 13:18
@S7evinK
Copy link
Contributor

S7evinK commented Sep 22, 2024

Sorry for closing this, feel free to join #dendrite-dev:matrix.org for further discussion.

@S7evinK S7evinK closed this Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants